{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>新增机构</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" name="add_edu" id="add_edu" method="post" action="{:url('add_edu')}">

                        {if condition="$pid eq 0"}
                        <div class="form-group">
                            <label class="col-sm-3 control-label">上级机构</label>
                            <div class="col-sm-4">
                                <select name="pid" class="form-control">
                                    <option value="0">--默认顶级--</option>
                                    {foreach name="list" item="v"}
                                    <option value="{$v.id}" style="margin-left:55px;">{$v.lefthtml}{$v.name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        {else/}
                        <input type="hidden" name="pid" value="{$pid}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">上级机构</label>
                            <div class="col-sm-4">
                                <select name="pid" class="form-control">
                                    <option value="{$pid}" style="margin-left:55px;">{$father.name}</option>
                                </select>
                            </div>
                        </div>
                        {/if}

                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">机构名称：</label>
                            <div class="input-group col-sm-4">
                                <input id="name" type="text" class="form-control" name="name" required="" aria-required="true" >
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">机构帐号：</label>
                            <div class="input-group col-sm-4">
                                <input id="account" type="text" class="form-control" name="account" >
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">机构类型：</label>
                            <div class="input-group col-sm-4">
                                <select name="school" class="form-control">
                                    <option value="0" >请选择</option>
                                    <option value="1" >小学</option>
                                    <option value="2" >初中</option>
                                    <option value="3" >高中</option>
                                    <option value="4" >教育局</option>
                                    <option value="5" >编辑部</option>
                                </select>
                            </div>
                        </div>

                        <!--<div class="hr-line-dashed"></div>-->
                        <div class="form-group" style="display: none;">
                            <label class="col-sm-3 control-label"> 状&nbsp;态：</label>
                            <div class="input-group col-sm-4" style="padding-top:5px;">
                                <input name="status" id="status" value="1" class="js-switch" type="checkbox" checked />
                                <span class="lbl">&nbsp;&nbsp;默认开启</span>
                            </div>
                        </div>

                        <!--<div class="hr-line-dashed"></div>-->
                        <!--<div class="form-group">-->
                            <!--<label class="col-sm-3 control-label"> 排序：</label>-->
                            <!--<div class="input-group col-sm-5">-->
                                <!--<input type="text" name="sort" id="sort" value="50" placeholder="输入排序"  class="form-control" />-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">

    $(function(){
        $('#add_edu').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });

        function checkForm(){
            if( '' == $.trim($('#name').val())){
                layer.msg('请输入机构名称',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('Instit/edu')}";
                });
            }else{
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1});
                return false;
            }
        }

    });



    //IOS开关样式配置
    var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, {
        color: '#1AB394'
    });
    var config = {
        '.chosen-select': {},
    }
    for (var selector in config) {
        $(selector).chosen(config[selector]);
    }

</script>
</body>
</html>